import { defineStore } from 'pinia'
import defaultSettings from '@/config/settings.json'
export const useAppStore = defineStore('app', {
  state: () => ({ ...defaultSettings }),
  getters: {
    appCurrentSetting(state) {
      return { ...state }
    },
  },
  actions: {
    // Update app settings
    updateSettings(partial) {
      // @ts-ignore
      this.$patch(partial)
    },
    // Change theme color
    toggleTheme(dark) {
      if (dark) {
        this.theme = 'dark'
        document.body.setAttribute('arco-theme', 'dark')
      }
      else {
        this.theme = 'light'
        document.body.removeAttribute('arco-theme')
      }
    },
  },
})